{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "id": "6ijFzT9ch7zn"
   },
   "outputs": [
    {
     "ename": "MemoryError",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[1;31mMemoryError\u001B[0m                               Traceback (most recent call last)",
      "Cell \u001B[1;32mIn [2], line 3\u001B[0m\n\u001B[0;32m      1\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m \u001B[38;5;21;01mos\u001B[39;00m\n\u001B[0;32m      2\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m \u001B[38;5;21;01msys\u001B[39;00m\n\u001B[1;32m----> 3\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m \u001B[38;5;21;01mtorch\u001B[39;00m\n\u001B[0;32m      4\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mtorch\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m nn\n\u001B[0;32m      5\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m \u001B[38;5;21;01mtorchvision\u001B[39;00m\n",
      "File \u001B[1;32mD:\\python\\lib\\site-packages\\torch\\__init__.py:886\u001B[0m\n\u001B[0;32m    883\u001B[0m _C._init_names(list(torch._storage_classes))\n\u001B[0;32m    885\u001B[0m # attach docstrings to torch and tensor functions\n\u001B[1;32m--> 886\u001B[0m from . import _torch_docs, _tensor_docs, _storage_docs\n\u001B[0;32m    887\u001B[0m del _torch_docs, _tensor_docs, _storage_docs\n\u001B[0;32m    890\u001B[0m def compiled_with_cxx11_abi():\n",
      "File \u001B[1;32m<frozen importlib._bootstrap>:1007\u001B[0m, in \u001B[0;36m_find_and_load\u001B[1;34m(name, import_)\u001B[0m\n",
      "File \u001B[1;32m<frozen importlib._bootstrap>:986\u001B[0m, in \u001B[0;36m_find_and_load_unlocked\u001B[1;34m(name, import_)\u001B[0m\n",
      "File \u001B[1;32m<frozen importlib._bootstrap>:680\u001B[0m, in \u001B[0;36m_load_unlocked\u001B[1;34m(spec)\u001B[0m\n",
      "File \u001B[1;32m<frozen importlib._bootstrap_external>:846\u001B[0m, in \u001B[0;36mexec_module\u001B[1;34m(self, module)\u001B[0m\n",
      "File \u001B[1;32m<frozen importlib._bootstrap_external>:941\u001B[0m, in \u001B[0;36mget_code\u001B[1;34m(self, fullname)\u001B[0m\n",
      "File \u001B[1;32m<frozen importlib._bootstrap_external>:1040\u001B[0m, in \u001B[0;36mget_data\u001B[1;34m(self, path)\u001B[0m\n",
      "\u001B[1;31mMemoryError\u001B[0m: "
     ]
    }
   ],
   "source": [
    "import os\n",
    "import sys\n",
    "import torch\n",
    "from torch import nn\n",
    "import torchvision\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "ifsgi-Myjaat",
    "outputId": "346244f4-3b76-4479-ebd6-baf0977821ef"
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connection.py\", line 174, in _new_conn\n",
      "    conn = connection.create_connection(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\util\\connection.py\", line 95, in create_connection\n",
      "    raise err\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\util\\connection.py\", line 85, in create_connection\n",
      "    sock.connect(sa)\n",
      "TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 703, in urlopen\n",
      "    httplib_response = self._make_request(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 386, in _make_request\n",
      "    self._validate_conn(conn)\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 1042, in _validate_conn\n",
      "    conn.connect()\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connection.py\", line 358, in connect\n",
      "    self.sock = conn = self._new_conn()\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connection.py\", line 186, in _new_conn\n",
      "    raise NewConnectionError(\n",
      "urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x0000014691831F10>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\adapters.py\", line 489, in send\n",
      "    resp = conn.urlopen(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 787, in urlopen\n",
      "    retries = retries.increment(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\util\\retry.py\", line 592, in increment\n",
      "    raise MaxRetryError(_pool, url, error or ResponseError(cause))\n",
      "urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='drive.google.com', port=443): Max retries exceeded with url: /uc?id=1_hFQP0zIsnkG_rkZtCSc_N5uya5P5Gb2 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000014691831F10>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。'))\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\runpy.py\", line 197, in _run_module_as_main\n",
      "    return _run_code(code, main_globals, None,\n",
      "  File \"D:\\python\\lib\\runpy.py\", line 87, in _run_code\n",
      "    exec(code, run_globals)\n",
      "  File \"D:\\python\\Scripts\\gdown.exe\\__main__.py\", line 7, in <module>\n",
      "  File \"D:\\python\\lib\\site-packages\\gdown\\cli.py\", line 150, in main\n",
      "    filename = download(\n",
      "  File \"D:\\python\\lib\\site-packages\\gdown\\download.py\", line 146, in download\n",
      "    res = sess.get(url, headers=headers, stream=True, verify=verify)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\sessions.py\", line 600, in get\n",
      "    return self.request(\"GET\", url, **kwargs)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\sessions.py\", line 587, in request\n",
      "    resp = self.send(prep, **send_kwargs)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\sessions.py\", line 701, in send\n",
      "    r = adapter.send(request, **kwargs)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\adapters.py\", line 565, in send\n",
      "    raise ConnectionError(e, request=request)\n",
      "requests.exceptions.ConnectionError: HTTPSConnectionPool(host='drive.google.com', port=443): Max retries exceeded with url: /uc?id=1_hFQP0zIsnkG_rkZtCSc_N5uya5P5Gb2 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000014691831F10>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。'))\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connection.py\", line 174, in _new_conn\n",
      "    conn = connection.create_connection(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\util\\connection.py\", line 95, in create_connection\n",
      "    raise err\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\util\\connection.py\", line 85, in create_connection\n",
      "    sock.connect(sa)\n",
      "TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 703, in urlopen\n",
      "    httplib_response = self._make_request(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 386, in _make_request\n",
      "    self._validate_conn(conn)\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 1042, in _validate_conn\n",
      "    conn.connect()\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connection.py\", line 358, in connect\n",
      "    self.sock = conn = self._new_conn()\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connection.py\", line 186, in _new_conn\n",
      "    raise NewConnectionError(\n",
      "urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x000001DE351470D0>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\adapters.py\", line 489, in send\n",
      "    resp = conn.urlopen(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 787, in urlopen\n",
      "    retries = retries.increment(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\util\\retry.py\", line 592, in increment\n",
      "    raise MaxRetryError(_pool, url, error or ResponseError(cause))\n",
      "urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='drive.google.com', port=443): Max retries exceeded with url: /uc?id=1vNblxEmLK9tdVDk0uAKVCE0kqz3wVjYO (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001DE351470D0>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。'))\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\runpy.py\", line 197, in _run_module_as_main\n",
      "    return _run_code(code, main_globals, None,\n",
      "  File \"D:\\python\\lib\\runpy.py\", line 87, in _run_code\n",
      "    exec(code, run_globals)\n",
      "  File \"D:\\python\\Scripts\\gdown.exe\\__main__.py\", line 7, in <module>\n",
      "  File \"D:\\python\\lib\\site-packages\\gdown\\cli.py\", line 150, in main\n",
      "    filename = download(\n",
      "  File \"D:\\python\\lib\\site-packages\\gdown\\download.py\", line 146, in download\n",
      "    res = sess.get(url, headers=headers, stream=True, verify=verify)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\sessions.py\", line 600, in get\n",
      "    return self.request(\"GET\", url, **kwargs)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\sessions.py\", line 587, in request\n",
      "    resp = self.send(prep, **send_kwargs)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\sessions.py\", line 701, in send\n",
      "    r = adapter.send(request, **kwargs)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\adapters.py\", line 565, in send\n",
      "    raise ConnectionError(e, request=request)\n",
      "requests.exceptions.ConnectionError: HTTPSConnectionPool(host='drive.google.com', port=443): Max retries exceeded with url: /uc?id=1vNblxEmLK9tdVDk0uAKVCE0kqz3wVjYO (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001DE351470D0>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。'))\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connection.py\", line 174, in _new_conn\n",
      "    conn = connection.create_connection(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\util\\connection.py\", line 95, in create_connection\n",
      "    raise err\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\util\\connection.py\", line 85, in create_connection\n",
      "    sock.connect(sa)\n",
      "TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 703, in urlopen\n",
      "    httplib_response = self._make_request(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 386, in _make_request\n",
      "    self._validate_conn(conn)\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 1042, in _validate_conn\n",
      "    conn.connect()\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connection.py\", line 358, in connect\n",
      "    self.sock = conn = self._new_conn()\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connection.py\", line 186, in _new_conn\n",
      "    raise NewConnectionError(\n",
      "urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x0000023927131EE0>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\adapters.py\", line 489, in send\n",
      "    resp = conn.urlopen(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\connectionpool.py\", line 787, in urlopen\n",
      "    retries = retries.increment(\n",
      "  File \"D:\\python\\lib\\site-packages\\urllib3\\util\\retry.py\", line 592, in increment\n",
      "    raise MaxRetryError(_pool, url, error or ResponseError(cause))\n",
      "urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='drive.google.com', port=443): Max retries exceeded with url: /uc?id=1eL3ijRv05AamR_NTwFV86cH3ig6sb6nE (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000023927131EE0>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。'))\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"D:\\python\\lib\\runpy.py\", line 197, in _run_module_as_main\n",
      "    return _run_code(code, main_globals, None,\n",
      "  File \"D:\\python\\lib\\runpy.py\", line 87, in _run_code\n",
      "    exec(code, run_globals)\n",
      "  File \"D:\\python\\Scripts\\gdown.exe\\__main__.py\", line 7, in <module>\n",
      "  File \"D:\\python\\lib\\site-packages\\gdown\\cli.py\", line 150, in main\n",
      "    filename = download(\n",
      "  File \"D:\\python\\lib\\site-packages\\gdown\\download.py\", line 146, in download\n",
      "    res = sess.get(url, headers=headers, stream=True, verify=verify)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\sessions.py\", line 600, in get\n",
      "    return self.request(\"GET\", url, **kwargs)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\sessions.py\", line 587, in request\n",
      "    resp = self.send(prep, **send_kwargs)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\sessions.py\", line 701, in send\n",
      "    r = adapter.send(request, **kwargs)\n",
      "  File \"D:\\python\\lib\\site-packages\\requests\\adapters.py\", line 565, in send\n",
      "    raise ConnectionError(e, request=request)\n",
      "requests.exceptions.ConnectionError: HTTPSConnectionPool(host='drive.google.com', port=443): Max retries exceeded with url: /uc?id=1eL3ijRv05AamR_NTwFV86cH3ig6sb6nE (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000023927131EE0>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应，连接尝试失败。'))\n"
     ]
    }
   ],
   "source": [
    "fn_lst = [\"https://drive.google.com/file/d/1_hFQP0zIsnkG_rkZtCSc_N5uya5P5Gb2/view?usp=sharing\",\n",
    "          \"https://drive.google.com/file/d/1vNblxEmLK9tdVDk0uAKVCE0kqz3wVjYO/view?usp=sharing\",\n",
    "          \"https://drive.google.com/file/d/1eL3ijRv05AamR_NTwFV86cH3ig6sb6nE/view?usp=sharing\"]\n",
    "for fn in fn_lst:\n",
    "  !gdown --fuzzy $fn\n",
    "\n",
    "files = list(sorted(os.listdir(\".\")))\n",
    "npz_files = [f for f in files if f.endswith(\"npz\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "F-b0UW6bkzCI"
   },
   "outputs": [],
   "source": [
    "class PtCoordDataset(torch.utils.data.Dataset):\n",
    "  def __init__(self, npz_files, if_train=True, transform=None):\n",
    "    X_lst = []\n",
    "    Y_lst = []\n",
    "    n_sample = 0\n",
    "    for npz in npz_files:\n",
    "      data = np.load(npz)\n",
    "      X = data['arr_0']\n",
    "      Y = data['arr_1']\n",
    "      X_lst.append(X)\n",
    "      Y_lst.append(Y)\n",
    "\n",
    "      n_sample += len(Y)\n",
    "    #unite all the data to one \n",
    "    X = np.zeros((33,33,n_sample))\n",
    "    Y = np.zeros((n_sample, 1))\n",
    "    offset = 0\n",
    "    for i in range(len(Y_lst)):\n",
    "      n=len(Y_lst[i])\n",
    "      X[:,:,offset:offset+n] = X_lst[i]\n",
    "      Y[offset:offset+n] = Y_lst[i]\n",
    "      offset += n\n",
    "    \n",
    "    #三分之二用作训练，三分之一用作测试\n",
    "    if if_train==True:\n",
    "      ind_lst1 = [v for v in range(0,n_sample,3)]\n",
    "      ind_lst2 =[v for v in range(1,n_sample,3)]\n",
    "\n",
    "      selected_ind = ind_lst1+ind_lst2\n",
    "    else:\n",
    "      selected_ind = [v for v in range(2,n_sample,3)]\n",
    "    \n",
    "    X = X.take(selected_ind, axis=2)\n",
    "    Y = Y.take(selected_ind, axis=0)    \n",
    "\n",
    "    self.X = X.astype(np.float32)\n",
    "    self.Y = Y.astype(np.float32)\n",
    "    self.transform = transform\n",
    "\n",
    "  def __len__(self):\n",
    "    return len(self.Y)\n",
    "  \n",
    "  def __getitem__(self, idx):\n",
    "    x = self.X[:,:,idx]\n",
    "    y = self.Y[idx]\n",
    "    if self.transform:\n",
    "      x = self.transform(x)\n",
    "\n",
    "    #把y转换为one-hot格式，便于用后面的交叉熵loss\n",
    "    y_onehot = np.zeros((10))\n",
    "    y_onehot[int(y)]=1\n",
    "    \n",
    "    return {'x':torch.unsqueeze(torch.from_numpy(x), 0),'y':torch.from_numpy(y_onehot)}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "qt2na8tpO2e8"
   },
   "outputs": [],
   "source": [
    "batchSz = 100\n",
    "train_dset = PtCoordDataset(npz_files)\n",
    "test_dset = PtCoordDataset(npz_files, if_train=False)\n",
    "\n",
    "train_dataloader = torch.utils.data.DataLoader(train_dset, batch_size=batchSz,\n",
    "                        shuffle=True, num_workers=0)\n",
    "test_dataloader = torch.utils.data.DataLoader(test_dset, batch_size=batchSz,\n",
    "                        shuffle=False, num_workers=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "mozpABqCUEx4"
   },
   "outputs": [],
   "source": [
    "class LCnn(nn.Module):\n",
    "    def __init__(self):\n",
    "        super(LCnn, self).__init__()\n",
    "        \n",
    "        self.linear_relu_stack = nn.Sequential(\n",
    "            nn.Conv2d(1,8,kernel_size=9,stride=2),\n",
    "            nn.ReLU(),\n",
    "            nn.Conv2d(8,16,kernel_size=3, stride=2),\n",
    "            nn.ReLU(),\n",
    "            nn.Conv2d(16,10, kernel_size=1),\n",
    "            nn.ReLU(),\n",
    "            nn.AdaptiveAvgPool2d(1),\n",
    "            nn.Flatten(),\n",
    "            nn.Softmax()\n",
    "        )\n",
    "\n",
    "    def forward(self, x):        \n",
    "        logits = self.linear_relu_stack(x)\n",
    "        return logits\n",
    "\n",
    "model = LCnn()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "AZAY0d3YEBU0"
   },
   "outputs": [],
   "source": [
    "class LCnn2(nn.Module):\n",
    "    def __init__(self):\n",
    "        super(LCnn2, self).__init__()\n",
    "        \n",
    "        self.linear_relu_stack = nn.Sequential(\n",
    "            nn.Conv2d(1,12,kernel_size=9,stride=2),\n",
    "            nn.ReLU(),\n",
    "            nn.Conv2d(12,32,kernel_size=3, stride=2),\n",
    "            nn.ReLU(),\n",
    "            nn.Conv2d(32,10, kernel_size=1),\n",
    "            nn.ReLU(),\n",
    "            nn.Flatten(),\n",
    "            nn.Linear(360,10),\n",
    "            \n",
    "            nn.Softmax()\n",
    "        )\n",
    "\n",
    "    def forward(self, x):        \n",
    "        logits = self.linear_relu_stack(x)\n",
    "        return logits\n",
    "\n",
    "model = LCnn2()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "50H9OaewCf2H"
   },
   "outputs": [],
   "source": [
    "learning_rate = 0.01\n",
    "epochs = 500\n",
    "\n",
    "loss_fn = nn.CrossEntropyLoss()\n",
    "optimizer = torch.optim.SGD(model.parameters(), lr=learning_rate, momentum=0.95)\n",
    "\n",
    "def train_loop(dataloader, model, loss_fn, optimizer):\n",
    "    size = len(dataloader.dataset)\n",
    "    for batch, dat in enumerate(dataloader):\n",
    "        X = dat['x']\n",
    "        y = dat['y']\n",
    "        # Compute prediction and loss\n",
    "        pred = model(X)\n",
    "        loss = loss_fn(pred, y)\n",
    "\n",
    "        # Backpropagation\n",
    "        optimizer.zero_grad()\n",
    "        loss.backward()\n",
    "        optimizer.step()\n",
    "\n",
    "        if batch % 10 == 0:\n",
    "            loss, current = loss.item(), batch * len(X)\n",
    "            print(f\"loss: {loss:>7f}  [{current:>5d}/{size:>5d}]\")\n",
    "\n",
    "\n",
    "def test_loop(dataloader, model, loss_fn):\n",
    "    size = len(dataloader.dataset)\n",
    "    num_batches = len(dataloader)\n",
    "    test_loss, correct = 0, 0\n",
    "\n",
    "    with torch.no_grad():\n",
    "        for dat in dataloader:\n",
    "            X = dat['x']\n",
    "            y = dat['y']\n",
    "            pred = model(X)\n",
    "            test_loss += loss_fn(pred, y).item()\n",
    "            correct += (pred.argmax(1) == y.argmax(1)).type(torch.float).sum().item()\n",
    "\n",
    "    test_loss /= num_batches\n",
    "    correct /= size\n",
    "    print(f\"Test Error: \\n Accuracy: {(100*correct):>0.1f}%, Avg loss: {test_loss:>8f} \\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "_ez6HE-4HAli"
   },
   "outputs": [],
   "source": [
    "#需要重新训练的话，就运行本段\n",
    "for layer in model.children():\n",
    "   if hasattr(layer, 'reset_parameters'):\n",
    "       layer.reset_parameters()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "FGAfzegrD2Fm",
    "outputId": "96e799c6-1add-4717-a88b-769197aaacf9"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1\n",
      "-------------------------------\n",
      "loss: 1.549638  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833645 \n",
      "\n",
      "Epoch 2\n",
      "-------------------------------\n",
      "loss: 1.540428  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833596 \n",
      "\n",
      "Epoch 3\n",
      "-------------------------------\n",
      "loss: 1.550256  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833678 \n",
      "\n",
      "Epoch 4\n",
      "-------------------------------\n",
      "loss: 1.559525  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833519 \n",
      "\n",
      "Epoch 5\n",
      "-------------------------------\n",
      "loss: 1.559911  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833310 \n",
      "\n",
      "Epoch 6\n",
      "-------------------------------\n",
      "loss: 1.568844  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833117 \n",
      "\n",
      "Epoch 7\n",
      "-------------------------------\n",
      "loss: 1.539546  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833136 \n",
      "\n",
      "Epoch 8\n",
      "-------------------------------\n",
      "loss: 1.570336  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833445 \n",
      "\n",
      "Epoch 9\n",
      "-------------------------------\n",
      "loss: 1.530701  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.834020 \n",
      "\n",
      "Epoch 10\n",
      "-------------------------------\n",
      "loss: 1.549533  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833893 \n",
      "\n",
      "Epoch 11\n",
      "-------------------------------\n",
      "loss: 1.579523  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833611 \n",
      "\n",
      "Epoch 12\n",
      "-------------------------------\n",
      "loss: 1.539991  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833415 \n",
      "\n",
      "Epoch 13\n",
      "-------------------------------\n",
      "loss: 1.549880  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833369 \n",
      "\n",
      "Epoch 14\n",
      "-------------------------------\n",
      "loss: 1.569618  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833504 \n",
      "\n",
      "Epoch 15\n",
      "-------------------------------\n",
      "loss: 1.579976  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833527 \n",
      "\n",
      "Epoch 16\n",
      "-------------------------------\n",
      "loss: 1.560340  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833441 \n",
      "\n",
      "Epoch 17\n",
      "-------------------------------\n",
      "loss: 1.559789  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833272 \n",
      "\n",
      "Epoch 18\n",
      "-------------------------------\n",
      "loss: 1.550338  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833195 \n",
      "\n",
      "Epoch 19\n",
      "-------------------------------\n",
      "loss: 1.559514  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833261 \n",
      "\n",
      "Epoch 20\n",
      "-------------------------------\n",
      "loss: 1.549509  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833456 \n",
      "\n",
      "Epoch 21\n",
      "-------------------------------\n",
      "loss: 1.540436  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833583 \n",
      "\n",
      "Epoch 22\n",
      "-------------------------------\n",
      "loss: 1.579517  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833455 \n",
      "\n",
      "Epoch 23\n",
      "-------------------------------\n",
      "loss: 1.550335  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833231 \n",
      "\n",
      "Epoch 24\n",
      "-------------------------------\n",
      "loss: 1.559974  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833142 \n",
      "\n",
      "Epoch 25\n",
      "-------------------------------\n",
      "loss: 1.530691  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833252 \n",
      "\n",
      "Epoch 26\n",
      "-------------------------------\n",
      "loss: 1.569498  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833430 \n",
      "\n",
      "Epoch 27\n",
      "-------------------------------\n",
      "loss: 1.569526  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833403 \n",
      "\n",
      "Epoch 28\n",
      "-------------------------------\n",
      "loss: 1.560331  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833248 \n",
      "\n",
      "Epoch 29\n",
      "-------------------------------\n",
      "loss: 1.588761  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.832921 \n",
      "\n",
      "Epoch 30\n",
      "-------------------------------\n",
      "loss: 1.530781  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.832823 \n",
      "\n",
      "Epoch 31\n",
      "-------------------------------\n",
      "loss: 1.539506  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.832993 \n",
      "\n",
      "Epoch 32\n",
      "-------------------------------\n",
      "loss: 1.510807  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833216 \n",
      "\n",
      "Epoch 33\n",
      "-------------------------------\n",
      "loss: 1.520343  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833275 \n",
      "\n",
      "Epoch 34\n",
      "-------------------------------\n",
      "loss: 1.540247  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833162 \n",
      "\n",
      "Epoch 35\n",
      "-------------------------------\n",
      "loss: 1.559721  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833028 \n",
      "\n",
      "Epoch 36\n",
      "-------------------------------\n",
      "loss: 1.570801  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833020 \n",
      "\n",
      "Epoch 37\n",
      "-------------------------------\n",
      "loss: 1.530455  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.832779 \n",
      "\n",
      "Epoch 38\n",
      "-------------------------------\n",
      "loss: 1.559297  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.832920 \n",
      "\n",
      "Epoch 39\n",
      "-------------------------------\n",
      "loss: 1.539684  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833197 \n",
      "\n",
      "Epoch 40\n",
      "-------------------------------\n",
      "loss: 1.579188  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833370 \n",
      "\n",
      "Epoch 41\n",
      "-------------------------------\n",
      "loss: 1.529889  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833143 \n",
      "\n",
      "Epoch 42\n",
      "-------------------------------\n",
      "loss: 1.519972  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.832883 \n",
      "\n",
      "Epoch 43\n",
      "-------------------------------\n",
      "loss: 1.529554  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.832998 \n",
      "\n",
      "Epoch 44\n",
      "-------------------------------\n",
      "loss: 1.580017  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833080 \n",
      "\n",
      "Epoch 45\n",
      "-------------------------------\n",
      "loss: 1.549459  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833009 \n",
      "\n",
      "Epoch 46\n",
      "-------------------------------\n",
      "loss: 1.539977  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833308 \n",
      "\n",
      "Epoch 47\n",
      "-------------------------------\n",
      "loss: 1.580065  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 58.3%, Avg loss: 1.836162 \n",
      "\n",
      "Epoch 48\n",
      "-------------------------------\n",
      "loss: 1.569367  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837369 \n",
      "\n",
      "Epoch 49\n",
      "-------------------------------\n",
      "loss: 1.579390  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837320 \n",
      "\n",
      "Epoch 50\n",
      "-------------------------------\n",
      "loss: 1.560165  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836735 \n",
      "\n",
      "Epoch 51\n",
      "-------------------------------\n",
      "loss: 1.540469  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834602 \n",
      "\n",
      "Epoch 52\n",
      "-------------------------------\n",
      "loss: 1.599186  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.833517 \n",
      "\n",
      "Epoch 53\n",
      "-------------------------------\n",
      "loss: 1.579590  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 58.3%, Avg loss: 1.837297 \n",
      "\n",
      "Epoch 54\n",
      "-------------------------------\n",
      "loss: 1.550475  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 57.4%, Avg loss: 1.840209 \n",
      "\n",
      "Epoch 55\n",
      "-------------------------------\n",
      "loss: 1.520390  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 57.4%, Avg loss: 1.840978 \n",
      "\n",
      "Epoch 56\n",
      "-------------------------------\n",
      "loss: 1.540415  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 58.3%, Avg loss: 1.841276 \n",
      "\n",
      "Epoch 57\n",
      "-------------------------------\n",
      "loss: 1.529726  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 58.3%, Avg loss: 1.841543 \n",
      "\n",
      "Epoch 58\n",
      "-------------------------------\n",
      "loss: 1.550815  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 57.4%, Avg loss: 1.841838 \n",
      "\n",
      "Epoch 59\n",
      "-------------------------------\n",
      "loss: 1.559994  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 57.4%, Avg loss: 1.842037 \n",
      "\n",
      "Epoch 60\n",
      "-------------------------------\n",
      "loss: 1.560344  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 57.4%, Avg loss: 1.841897 \n",
      "\n",
      "Epoch 61\n",
      "-------------------------------\n",
      "loss: 1.530433  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 57.4%, Avg loss: 1.841769 \n",
      "\n",
      "Epoch 62\n",
      "-------------------------------\n",
      "loss: 1.549623  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 58.3%, Avg loss: 1.841745 \n",
      "\n",
      "Epoch 63\n",
      "-------------------------------\n",
      "loss: 1.559621  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 58.3%, Avg loss: 1.841634 \n",
      "\n",
      "Epoch 64\n",
      "-------------------------------\n",
      "loss: 1.539719  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 57.4%, Avg loss: 1.841472 \n",
      "\n",
      "Epoch 65\n",
      "-------------------------------\n",
      "loss: 1.530791  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 57.4%, Avg loss: 1.841035 \n",
      "\n",
      "Epoch 66\n",
      "-------------------------------\n",
      "loss: 1.549947  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 57.4%, Avg loss: 1.840489 \n",
      "\n",
      "Epoch 67\n",
      "-------------------------------\n",
      "loss: 1.589743  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 58.3%, Avg loss: 1.839150 \n",
      "\n",
      "Epoch 68\n",
      "-------------------------------\n",
      "loss: 1.549411  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835976 \n",
      "\n",
      "Epoch 69\n",
      "-------------------------------\n",
      "loss: 1.569953  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834193 \n",
      "\n",
      "Epoch 70\n",
      "-------------------------------\n",
      "loss: 1.569953  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836249 \n",
      "\n",
      "Epoch 71\n",
      "-------------------------------\n",
      "loss: 1.559144  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837319 \n",
      "\n",
      "Epoch 72\n",
      "-------------------------------\n",
      "loss: 1.539613  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837809 \n",
      "\n",
      "Epoch 73\n",
      "-------------------------------\n",
      "loss: 1.560134  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837965 \n",
      "\n",
      "Epoch 74\n",
      "-------------------------------\n",
      "loss: 1.569341  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837333 \n",
      "\n",
      "Epoch 75\n",
      "-------------------------------\n",
      "loss: 1.580439  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836737 \n",
      "\n",
      "Epoch 76\n",
      "-------------------------------\n",
      "loss: 1.559953  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836260 \n",
      "\n",
      "Epoch 77\n",
      "-------------------------------\n",
      "loss: 1.580645  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836371 \n",
      "\n",
      "Epoch 78\n",
      "-------------------------------\n",
      "loss: 1.510696  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836963 \n",
      "\n",
      "Epoch 79\n",
      "-------------------------------\n",
      "loss: 1.559687  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837682 \n",
      "\n",
      "Epoch 80\n",
      "-------------------------------\n",
      "loss: 1.570475  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837846 \n",
      "\n",
      "Epoch 81\n",
      "-------------------------------\n",
      "loss: 1.569373  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837414 \n",
      "\n",
      "Epoch 82\n",
      "-------------------------------\n",
      "loss: 1.530333  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836941 \n",
      "\n",
      "Epoch 83\n",
      "-------------------------------\n",
      "loss: 1.589454  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836680 \n",
      "\n",
      "Epoch 84\n",
      "-------------------------------\n",
      "loss: 1.559575  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836940 \n",
      "\n",
      "Epoch 85\n",
      "-------------------------------\n",
      "loss: 1.540824  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.837192 \n",
      "\n",
      "Epoch 86\n",
      "-------------------------------\n",
      "loss: 1.569506  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.837099 \n",
      "\n",
      "Epoch 87\n",
      "-------------------------------\n",
      "loss: 1.550383  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836949 \n",
      "\n",
      "Epoch 88\n",
      "-------------------------------\n",
      "loss: 1.520148  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836679 \n",
      "\n",
      "Epoch 89\n",
      "-------------------------------\n",
      "loss: 1.569179  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836460 \n",
      "\n",
      "Epoch 90\n",
      "-------------------------------\n",
      "loss: 1.560134  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836681 \n",
      "\n",
      "Epoch 91\n",
      "-------------------------------\n",
      "loss: 1.550460  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.837029 \n",
      "\n",
      "Epoch 92\n",
      "-------------------------------\n",
      "loss: 1.550819  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.837293 \n",
      "\n",
      "Epoch 93\n",
      "-------------------------------\n",
      "loss: 1.539941  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.837216 \n",
      "\n",
      "Epoch 94\n",
      "-------------------------------\n",
      "loss: 1.530339  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836901 \n",
      "\n",
      "Epoch 95\n",
      "-------------------------------\n",
      "loss: 1.540342  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836518 \n",
      "\n",
      "Epoch 96\n",
      "-------------------------------\n",
      "loss: 1.540084  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836493 \n",
      "\n",
      "Epoch 97\n",
      "-------------------------------\n",
      "loss: 1.530440  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836788 \n",
      "\n",
      "Epoch 98\n",
      "-------------------------------\n",
      "loss: 1.549317  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.837105 \n",
      "\n",
      "Epoch 99\n",
      "-------------------------------\n",
      "loss: 1.610329  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.837205 \n",
      "\n",
      "Epoch 100\n",
      "-------------------------------\n",
      "loss: 1.569727  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836967 \n",
      "\n",
      "Epoch 101\n",
      "-------------------------------\n",
      "loss: 1.530802  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836625 \n",
      "\n",
      "Epoch 102\n",
      "-------------------------------\n",
      "loss: 1.569988  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836607 \n",
      "\n",
      "Epoch 103\n",
      "-------------------------------\n",
      "loss: 1.519917  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836951 \n",
      "\n",
      "Epoch 104\n",
      "-------------------------------\n",
      "loss: 1.539991  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.837031 \n",
      "\n",
      "Epoch 105\n",
      "-------------------------------\n",
      "loss: 1.539670  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836923 \n",
      "\n",
      "Epoch 106\n",
      "-------------------------------\n",
      "loss: 1.579554  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836796 \n",
      "\n",
      "Epoch 107\n",
      "-------------------------------\n",
      "loss: 1.519904  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836722 \n",
      "\n",
      "Epoch 108\n",
      "-------------------------------\n",
      "loss: 1.569513  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836747 \n",
      "\n",
      "Epoch 109\n",
      "-------------------------------\n",
      "loss: 1.550015  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836805 \n",
      "\n",
      "Epoch 110\n",
      "-------------------------------\n",
      "loss: 1.559517  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836888 \n",
      "\n",
      "Epoch 111\n",
      "-------------------------------\n",
      "loss: 1.539875  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836783 \n",
      "\n",
      "Epoch 112\n",
      "-------------------------------\n",
      "loss: 1.520357  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836659 \n",
      "\n",
      "Epoch 113\n",
      "-------------------------------\n",
      "loss: 1.550459  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836728 \n",
      "\n",
      "Epoch 114\n",
      "-------------------------------\n",
      "loss: 1.530707  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836798 \n",
      "\n",
      "Epoch 115\n",
      "-------------------------------\n",
      "loss: 1.569509  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836822 \n",
      "\n",
      "Epoch 116\n",
      "-------------------------------\n",
      "loss: 1.539978  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836758 \n",
      "\n",
      "Epoch 117\n",
      "-------------------------------\n",
      "loss: 1.559974  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836657 \n",
      "\n",
      "Epoch 118\n",
      "-------------------------------\n",
      "loss: 1.598692  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836505 \n",
      "\n",
      "Epoch 119\n",
      "-------------------------------\n",
      "loss: 1.549897  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836528 \n",
      "\n",
      "Epoch 120\n",
      "-------------------------------\n",
      "loss: 1.540244  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836689 \n",
      "\n",
      "Epoch 121\n",
      "-------------------------------\n",
      "loss: 1.540697  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836843 \n",
      "\n",
      "Epoch 122\n",
      "-------------------------------\n",
      "loss: 1.549993  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836752 \n",
      "\n",
      "Epoch 123\n",
      "-------------------------------\n",
      "loss: 1.589050  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836395 \n",
      "\n",
      "Epoch 124\n",
      "-------------------------------\n",
      "loss: 1.539653  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836323 \n",
      "\n",
      "Epoch 125\n",
      "-------------------------------\n",
      "loss: 1.559896  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836526 \n",
      "\n",
      "Epoch 126\n",
      "-------------------------------\n",
      "loss: 1.550704  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836753 \n",
      "\n",
      "Epoch 127\n",
      "-------------------------------\n",
      "loss: 1.519967  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836834 \n",
      "\n",
      "Epoch 128\n",
      "-------------------------------\n",
      "loss: 1.550696  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836715 \n",
      "\n",
      "Epoch 129\n",
      "-------------------------------\n",
      "loss: 1.550236  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836536 \n",
      "\n",
      "Epoch 130\n",
      "-------------------------------\n",
      "loss: 1.569866  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836530 \n",
      "\n",
      "Epoch 131\n",
      "-------------------------------\n",
      "loss: 1.520437  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836737 \n",
      "\n",
      "Epoch 132\n",
      "-------------------------------\n",
      "loss: 1.559517  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836778 \n",
      "\n",
      "Epoch 133\n",
      "-------------------------------\n",
      "loss: 1.540336  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836662 \n",
      "\n",
      "Epoch 134\n",
      "-------------------------------\n",
      "loss: 1.529965  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836438 \n",
      "\n",
      "Epoch 135\n",
      "-------------------------------\n",
      "loss: 1.550338  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836411 \n",
      "\n",
      "Epoch 136\n",
      "-------------------------------\n",
      "loss: 1.530348  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836549 \n",
      "\n",
      "Epoch 137\n",
      "-------------------------------\n",
      "loss: 1.589399  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836737 \n",
      "\n",
      "Epoch 138\n",
      "-------------------------------\n",
      "loss: 1.559607  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836708 \n",
      "\n",
      "Epoch 139\n",
      "-------------------------------\n",
      "loss: 1.569141  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836543 \n",
      "\n",
      "Epoch 140\n",
      "-------------------------------\n",
      "loss: 1.559599  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836355 \n",
      "\n",
      "Epoch 141\n",
      "-------------------------------\n",
      "loss: 1.589149  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836378 \n",
      "\n",
      "Epoch 142\n",
      "-------------------------------\n",
      "loss: 1.549138  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836558 \n",
      "\n",
      "Epoch 143\n",
      "-------------------------------\n",
      "loss: 1.550332  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836631 \n",
      "\n",
      "Epoch 144\n",
      "-------------------------------\n",
      "loss: 1.569871  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836474 \n",
      "\n",
      "Epoch 145\n",
      "-------------------------------\n",
      "loss: 1.520334  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836393 \n",
      "\n",
      "Epoch 146\n",
      "-------------------------------\n",
      "loss: 1.519715  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836455 \n",
      "\n",
      "Epoch 147\n",
      "-------------------------------\n",
      "loss: 1.589148  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836596 \n",
      "\n",
      "Epoch 148\n",
      "-------------------------------\n",
      "loss: 1.549140  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836621 \n",
      "\n",
      "Epoch 149\n",
      "-------------------------------\n",
      "loss: 1.569138  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836530 \n",
      "\n",
      "Epoch 150\n",
      "-------------------------------\n",
      "loss: 1.530333  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836401 \n",
      "\n",
      "Epoch 151\n",
      "-------------------------------\n",
      "loss: 1.539967  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836391 \n",
      "\n",
      "Epoch 152\n",
      "-------------------------------\n",
      "loss: 1.550070  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836517 \n",
      "\n",
      "Epoch 153\n",
      "-------------------------------\n",
      "loss: 1.550703  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836537 \n",
      "\n",
      "Epoch 154\n",
      "-------------------------------\n",
      "loss: 1.550687  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836403 \n",
      "\n",
      "Epoch 155\n",
      "-------------------------------\n",
      "loss: 1.550328  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836337 \n",
      "\n",
      "Epoch 156\n",
      "-------------------------------\n",
      "loss: 1.549608  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836403 \n",
      "\n",
      "Epoch 157\n",
      "-------------------------------\n",
      "loss: 1.530230  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836449 \n",
      "\n",
      "Epoch 158\n",
      "-------------------------------\n",
      "loss: 1.520428  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836433 \n",
      "\n",
      "Epoch 159\n",
      "-------------------------------\n",
      "loss: 1.559599  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836364 \n",
      "\n",
      "Epoch 160\n",
      "-------------------------------\n",
      "loss: 1.540332  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836346 \n",
      "\n",
      "Epoch 161\n",
      "-------------------------------\n",
      "loss: 1.560334  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836382 \n",
      "\n",
      "Epoch 162\n",
      "-------------------------------\n",
      "loss: 1.520693  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836414 \n",
      "\n",
      "Epoch 163\n",
      "-------------------------------\n",
      "loss: 1.550327  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836399 \n",
      "\n",
      "Epoch 164\n",
      "-------------------------------\n",
      "loss: 1.579864  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836348 \n",
      "\n",
      "Epoch 165\n",
      "-------------------------------\n",
      "loss: 1.588763  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836300 \n",
      "\n",
      "Epoch 166\n",
      "-------------------------------\n",
      "loss: 1.589406  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836298 \n",
      "\n",
      "Epoch 167\n",
      "-------------------------------\n",
      "loss: 1.539965  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836314 \n",
      "\n",
      "Epoch 168\n",
      "-------------------------------\n",
      "loss: 1.579601  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836335 \n",
      "\n",
      "Epoch 169\n",
      "-------------------------------\n",
      "loss: 1.540422  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836324 \n",
      "\n",
      "Epoch 170\n",
      "-------------------------------\n",
      "loss: 1.540432  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836280 \n",
      "\n",
      "Epoch 171\n",
      "-------------------------------\n",
      "loss: 1.540331  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836239 \n",
      "\n",
      "Epoch 172\n",
      "-------------------------------\n",
      "loss: 1.569495  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836233 \n",
      "\n",
      "Epoch 173\n",
      "-------------------------------\n",
      "loss: 1.559497  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836246 \n",
      "\n",
      "Epoch 174\n",
      "-------------------------------\n",
      "loss: 1.540431  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836257 \n",
      "\n",
      "Epoch 175\n",
      "-------------------------------\n",
      "loss: 1.579402  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836236 \n",
      "\n",
      "Epoch 176\n",
      "-------------------------------\n",
      "loss: 1.540800  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836206 \n",
      "\n",
      "Epoch 177\n",
      "-------------------------------\n",
      "loss: 1.580228  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836178 \n",
      "\n",
      "Epoch 178\n",
      "-------------------------------\n",
      "loss: 1.579600  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836173 \n",
      "\n",
      "Epoch 179\n",
      "-------------------------------\n",
      "loss: 1.519960  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836191 \n",
      "\n",
      "Epoch 180\n",
      "-------------------------------\n",
      "loss: 1.579135  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836186 \n",
      "\n",
      "Epoch 181\n",
      "-------------------------------\n",
      "loss: 1.539412  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836160 \n",
      "\n",
      "Epoch 182\n",
      "-------------------------------\n",
      "loss: 1.589506  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836116 \n",
      "\n",
      "Epoch 183\n",
      "-------------------------------\n",
      "loss: 1.559509  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836091 \n",
      "\n",
      "Epoch 184\n",
      "-------------------------------\n",
      "loss: 1.540226  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836100 \n",
      "\n",
      "Epoch 185\n",
      "-------------------------------\n",
      "loss: 1.540701  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836110 \n",
      "\n",
      "Epoch 186\n",
      "-------------------------------\n",
      "loss: 1.560327  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836082 \n",
      "\n",
      "Epoch 187\n",
      "-------------------------------\n",
      "loss: 1.579132  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836022 \n",
      "\n",
      "Epoch 188\n",
      "-------------------------------\n",
      "loss: 1.569033  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835981 \n",
      "\n",
      "Epoch 189\n",
      "-------------------------------\n",
      "loss: 1.549965  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835980 \n",
      "\n",
      "Epoch 190\n",
      "-------------------------------\n",
      "loss: 1.570222  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836037 \n",
      "\n",
      "Epoch 191\n",
      "-------------------------------\n",
      "loss: 1.559869  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836045 \n",
      "\n",
      "Epoch 192\n",
      "-------------------------------\n",
      "loss: 1.550334  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836005 \n",
      "\n",
      "Epoch 193\n",
      "-------------------------------\n",
      "loss: 1.540231  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835902 \n",
      "\n",
      "Epoch 194\n",
      "-------------------------------\n",
      "loss: 1.549860  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835837 \n",
      "\n",
      "Epoch 195\n",
      "-------------------------------\n",
      "loss: 1.530425  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835836 \n",
      "\n",
      "Epoch 196\n",
      "-------------------------------\n",
      "loss: 1.549959  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835862 \n",
      "\n",
      "Epoch 197\n",
      "-------------------------------\n",
      "loss: 1.510695  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835809 \n",
      "\n",
      "Epoch 198\n",
      "-------------------------------\n",
      "loss: 1.560423  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835678 \n",
      "\n",
      "Epoch 199\n",
      "-------------------------------\n",
      "loss: 1.540333  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835638 \n",
      "\n",
      "Epoch 200\n",
      "-------------------------------\n",
      "loss: 1.539870  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835709 \n",
      "\n",
      "Epoch 201\n",
      "-------------------------------\n",
      "loss: 1.559504  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835725 \n",
      "\n",
      "Epoch 202\n",
      "-------------------------------\n",
      "loss: 1.540236  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835591 \n",
      "\n",
      "Epoch 203\n",
      "-------------------------------\n",
      "loss: 1.589496  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835351 \n",
      "\n",
      "Epoch 204\n",
      "-------------------------------\n",
      "loss: 1.539597  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835258 \n",
      "\n",
      "Epoch 205\n",
      "-------------------------------\n",
      "loss: 1.540332  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835166 \n",
      "\n",
      "Epoch 206\n",
      "-------------------------------\n",
      "loss: 1.559137  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835096 \n",
      "\n",
      "Epoch 207\n",
      "-------------------------------\n",
      "loss: 1.569583  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834974 \n",
      "\n",
      "Epoch 208\n",
      "-------------------------------\n",
      "loss: 1.530797  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834876 \n",
      "\n",
      "Epoch 209\n",
      "-------------------------------\n",
      "loss: 1.559963  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834833 \n",
      "\n",
      "Epoch 210\n",
      "-------------------------------\n",
      "loss: 1.539499  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834618 \n",
      "\n",
      "Epoch 211\n",
      "-------------------------------\n",
      "loss: 1.530778  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834263 \n",
      "\n",
      "Epoch 212\n",
      "-------------------------------\n",
      "loss: 1.529403  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833936 \n",
      "\n",
      "Epoch 213\n",
      "-------------------------------\n",
      "loss: 1.560329  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.833308 \n",
      "\n",
      "Epoch 214\n",
      "-------------------------------\n",
      "loss: 1.589453  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832816 \n",
      "\n",
      "Epoch 215\n",
      "-------------------------------\n",
      "loss: 1.579442  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832461 \n",
      "\n",
      "Epoch 216\n",
      "-------------------------------\n",
      "loss: 1.540328  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832113 \n",
      "\n",
      "Epoch 217\n",
      "-------------------------------\n",
      "loss: 1.569515  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831956 \n",
      "\n",
      "Epoch 218\n",
      "-------------------------------\n",
      "loss: 1.579463  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832000 \n",
      "\n",
      "Epoch 219\n",
      "-------------------------------\n",
      "loss: 1.550364  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832102 \n",
      "\n",
      "Epoch 220\n",
      "-------------------------------\n",
      "loss: 1.549901  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832075 \n",
      "\n",
      "Epoch 221\n",
      "-------------------------------\n",
      "loss: 1.540448  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831891 \n",
      "\n",
      "Epoch 222\n",
      "-------------------------------\n",
      "loss: 1.550333  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831561 \n",
      "\n",
      "Epoch 223\n",
      "-------------------------------\n",
      "loss: 1.520344  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831590 \n",
      "\n",
      "Epoch 224\n",
      "-------------------------------\n",
      "loss: 1.529767  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831929 \n",
      "\n",
      "Epoch 225\n",
      "-------------------------------\n",
      "loss: 1.609201  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832029 \n",
      "\n",
      "Epoch 226\n",
      "-------------------------------\n",
      "loss: 1.559259  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831883 \n",
      "\n",
      "Epoch 227\n",
      "-------------------------------\n",
      "loss: 1.539639  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831778 \n",
      "\n",
      "Epoch 228\n",
      "-------------------------------\n",
      "loss: 1.570329  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831839 \n",
      "\n",
      "Epoch 229\n",
      "-------------------------------\n",
      "loss: 1.588718  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832932 \n",
      "\n",
      "Epoch 230\n",
      "-------------------------------\n",
      "loss: 1.530309  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.834295 \n",
      "\n",
      "Epoch 231\n",
      "-------------------------------\n",
      "loss: 1.550442  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.834157 \n",
      "\n",
      "Epoch 232\n",
      "-------------------------------\n",
      "loss: 1.589735  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832414 \n",
      "\n",
      "Epoch 233\n",
      "-------------------------------\n",
      "loss: 1.579746  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831664 \n",
      "\n",
      "Epoch 234\n",
      "-------------------------------\n",
      "loss: 1.520248  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831706 \n",
      "\n",
      "Epoch 235\n",
      "-------------------------------\n",
      "loss: 1.570049  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832162 \n",
      "\n",
      "Epoch 236\n",
      "-------------------------------\n",
      "loss: 1.540804  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832477 \n",
      "\n",
      "Epoch 237\n",
      "-------------------------------\n",
      "loss: 1.530377  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831934 \n",
      "\n",
      "Epoch 238\n",
      "-------------------------------\n",
      "loss: 1.540023  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831762 \n",
      "\n",
      "Epoch 239\n",
      "-------------------------------\n",
      "loss: 1.550802  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832347 \n",
      "\n",
      "Epoch 240\n",
      "-------------------------------\n",
      "loss: 1.559621  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834919 \n",
      "\n",
      "Epoch 241\n",
      "-------------------------------\n",
      "loss: 1.520030  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836134 \n",
      "\n",
      "Epoch 242\n",
      "-------------------------------\n",
      "loss: 1.530503  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835891 \n",
      "\n",
      "Epoch 243\n",
      "-------------------------------\n",
      "loss: 1.580113  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834645 \n",
      "\n",
      "Epoch 244\n",
      "-------------------------------\n",
      "loss: 1.509972  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832082 \n",
      "\n",
      "Epoch 245\n",
      "-------------------------------\n",
      "loss: 1.579042  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831641 \n",
      "\n",
      "Epoch 246\n",
      "-------------------------------\n",
      "loss: 1.569522  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832096 \n",
      "\n",
      "Epoch 247\n",
      "-------------------------------\n",
      "loss: 1.589810  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.833123 \n",
      "\n",
      "Epoch 248\n",
      "-------------------------------\n",
      "loss: 1.569370  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.833393 \n",
      "\n",
      "Epoch 249\n",
      "-------------------------------\n",
      "loss: 1.579960  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832618 \n",
      "\n",
      "Epoch 250\n",
      "-------------------------------\n",
      "loss: 1.540041  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831655 \n",
      "\n",
      "Epoch 251\n",
      "-------------------------------\n",
      "loss: 1.520528  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831388 \n",
      "\n",
      "Epoch 252\n",
      "-------------------------------\n",
      "loss: 1.580266  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831371 \n",
      "\n",
      "Epoch 253\n",
      "-------------------------------\n",
      "loss: 1.540081  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.831426 \n",
      "\n",
      "Epoch 254\n",
      "-------------------------------\n",
      "loss: 1.540083  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834758 \n",
      "\n",
      "Epoch 255\n",
      "-------------------------------\n",
      "loss: 1.550170  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.837542 \n",
      "\n",
      "Epoch 256\n",
      "-------------------------------\n",
      "loss: 1.560435  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.838401 \n",
      "\n",
      "Epoch 257\n",
      "-------------------------------\n",
      "loss: 1.570034  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.839075 \n",
      "\n",
      "Epoch 258\n",
      "-------------------------------\n",
      "loss: 1.589739  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.839750 \n",
      "\n",
      "Epoch 259\n",
      "-------------------------------\n",
      "loss: 1.560023  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.840231 \n",
      "\n",
      "Epoch 260\n",
      "-------------------------------\n",
      "loss: 1.550336  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.840457 \n",
      "\n",
      "Epoch 261\n",
      "-------------------------------\n",
      "loss: 1.560025  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.840597 \n",
      "\n",
      "Epoch 262\n",
      "-------------------------------\n",
      "loss: 1.530751  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840576 \n",
      "\n",
      "Epoch 263\n",
      "-------------------------------\n",
      "loss: 1.589150  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840647 \n",
      "\n",
      "Epoch 264\n",
      "-------------------------------\n",
      "loss: 1.560678  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840557 \n",
      "\n",
      "Epoch 265\n",
      "-------------------------------\n",
      "loss: 1.559533  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840673 \n",
      "\n",
      "Epoch 266\n",
      "-------------------------------\n",
      "loss: 1.540517  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840761 \n",
      "\n",
      "Epoch 267\n",
      "-------------------------------\n",
      "loss: 1.530735  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840544 \n",
      "\n",
      "Epoch 268\n",
      "-------------------------------\n",
      "loss: 1.539775  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840171 \n",
      "\n",
      "Epoch 269\n",
      "-------------------------------\n",
      "loss: 1.549560  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840333 \n",
      "\n",
      "Epoch 270\n",
      "-------------------------------\n",
      "loss: 1.560078  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840117 \n",
      "\n",
      "Epoch 271\n",
      "-------------------------------\n",
      "loss: 1.520009  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839542 \n",
      "\n",
      "Epoch 272\n",
      "-------------------------------\n",
      "loss: 1.539558  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839497 \n",
      "\n",
      "Epoch 273\n",
      "-------------------------------\n",
      "loss: 1.570253  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840187 \n",
      "\n",
      "Epoch 274\n",
      "-------------------------------\n",
      "loss: 1.569708  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840706 \n",
      "\n",
      "Epoch 275\n",
      "-------------------------------\n",
      "loss: 1.530246  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840928 \n",
      "\n",
      "Epoch 276\n",
      "-------------------------------\n",
      "loss: 1.559803  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840854 \n",
      "\n",
      "Epoch 277\n",
      "-------------------------------\n",
      "loss: 1.529510  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840338 \n",
      "\n",
      "Epoch 278\n",
      "-------------------------------\n",
      "loss: 1.500700  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838957 \n",
      "\n",
      "Epoch 279\n",
      "-------------------------------\n",
      "loss: 1.629273  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838128 \n",
      "\n",
      "Epoch 280\n",
      "-------------------------------\n",
      "loss: 1.530346  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838893 \n",
      "\n",
      "Epoch 281\n",
      "-------------------------------\n",
      "loss: 1.559481  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840108 \n",
      "\n",
      "Epoch 282\n",
      "-------------------------------\n",
      "loss: 1.530830  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840393 \n",
      "\n",
      "Epoch 283\n",
      "-------------------------------\n",
      "loss: 1.550638  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840122 \n",
      "\n",
      "Epoch 284\n",
      "-------------------------------\n",
      "loss: 1.540544  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839184 \n",
      "\n",
      "Epoch 285\n",
      "-------------------------------\n",
      "loss: 1.598464  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837807 \n",
      "\n",
      "Epoch 286\n",
      "-------------------------------\n",
      "loss: 1.569596  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838329 \n",
      "\n",
      "Epoch 287\n",
      "-------------------------------\n",
      "loss: 1.569810  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840101 \n",
      "\n",
      "Epoch 288\n",
      "-------------------------------\n",
      "loss: 1.559743  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840422 \n",
      "\n",
      "Epoch 289\n",
      "-------------------------------\n",
      "loss: 1.569900  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840313 \n",
      "\n",
      "Epoch 290\n",
      "-------------------------------\n",
      "loss: 1.530012  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839907 \n",
      "\n",
      "Epoch 291\n",
      "-------------------------------\n",
      "loss: 1.549543  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839258 \n",
      "\n",
      "Epoch 292\n",
      "-------------------------------\n",
      "loss: 1.549983  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838967 \n",
      "\n",
      "Epoch 293\n",
      "-------------------------------\n",
      "loss: 1.530094  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839274 \n",
      "\n",
      "Epoch 294\n",
      "-------------------------------\n",
      "loss: 1.549713  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839703 \n",
      "\n",
      "Epoch 295\n",
      "-------------------------------\n",
      "loss: 1.589301  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839484 \n",
      "\n",
      "Epoch 296\n",
      "-------------------------------\n",
      "loss: 1.579263  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838909 \n",
      "\n",
      "Epoch 297\n",
      "-------------------------------\n",
      "loss: 1.550433  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839022 \n",
      "\n",
      "Epoch 298\n",
      "-------------------------------\n",
      "loss: 1.598789  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839761 \n",
      "\n",
      "Epoch 299\n",
      "-------------------------------\n",
      "loss: 1.559192  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.840001 \n",
      "\n",
      "Epoch 300\n",
      "-------------------------------\n",
      "loss: 1.500816  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839595 \n",
      "\n",
      "Epoch 301\n",
      "-------------------------------\n",
      "loss: 1.560336  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838708 \n",
      "\n",
      "Epoch 302\n",
      "-------------------------------\n",
      "loss: 1.560066  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838279 \n",
      "\n",
      "Epoch 303\n",
      "-------------------------------\n",
      "loss: 1.559310  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839258 \n",
      "\n",
      "Epoch 304\n",
      "-------------------------------\n",
      "loss: 1.570017  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839584 \n",
      "\n",
      "Epoch 305\n",
      "-------------------------------\n",
      "loss: 1.559174  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839447 \n",
      "\n",
      "Epoch 306\n",
      "-------------------------------\n",
      "loss: 1.529517  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839108 \n",
      "\n",
      "Epoch 307\n",
      "-------------------------------\n",
      "loss: 1.568806  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838802 \n",
      "\n",
      "Epoch 308\n",
      "-------------------------------\n",
      "loss: 1.579145  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839061 \n",
      "\n",
      "Epoch 309\n",
      "-------------------------------\n",
      "loss: 1.549873  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839284 \n",
      "\n",
      "Epoch 310\n",
      "-------------------------------\n",
      "loss: 1.520442  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839163 \n",
      "\n",
      "Epoch 311\n",
      "-------------------------------\n",
      "loss: 1.520431  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838783 \n",
      "\n",
      "Epoch 312\n",
      "-------------------------------\n",
      "loss: 1.589298  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838670 \n",
      "\n",
      "Epoch 313\n",
      "-------------------------------\n",
      "loss: 1.559617  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838810 \n",
      "\n",
      "Epoch 314\n",
      "-------------------------------\n",
      "loss: 1.549717  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839077 \n",
      "\n",
      "Epoch 315\n",
      "-------------------------------\n",
      "loss: 1.569273  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838937 \n",
      "\n",
      "Epoch 316\n",
      "-------------------------------\n",
      "loss: 1.550069  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838436 \n",
      "\n",
      "Epoch 317\n",
      "-------------------------------\n",
      "loss: 1.539979  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838724 \n",
      "\n",
      "Epoch 318\n",
      "-------------------------------\n",
      "loss: 1.530819  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839581 \n",
      "\n",
      "Epoch 319\n",
      "-------------------------------\n",
      "loss: 1.558903  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839436 \n",
      "\n",
      "Epoch 320\n",
      "-------------------------------\n",
      "loss: 1.519989  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838964 \n",
      "\n",
      "Epoch 321\n",
      "-------------------------------\n",
      "loss: 1.549642  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838354 \n",
      "\n",
      "Epoch 322\n",
      "-------------------------------\n",
      "loss: 1.569197  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838454 \n",
      "\n",
      "Epoch 323\n",
      "-------------------------------\n",
      "loss: 1.520340  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838796 \n",
      "\n",
      "Epoch 324\n",
      "-------------------------------\n",
      "loss: 1.578677  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838811 \n",
      "\n",
      "Epoch 325\n",
      "-------------------------------\n",
      "loss: 1.569263  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837956 \n",
      "\n",
      "Epoch 326\n",
      "-------------------------------\n",
      "loss: 1.569515  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837827 \n",
      "\n",
      "Epoch 327\n",
      "-------------------------------\n",
      "loss: 1.569728  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838690 \n",
      "\n",
      "Epoch 328\n",
      "-------------------------------\n",
      "loss: 1.589145  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839532 \n",
      "\n",
      "Epoch 329\n",
      "-------------------------------\n",
      "loss: 1.579526  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839593 \n",
      "\n",
      "Epoch 330\n",
      "-------------------------------\n",
      "loss: 1.549297  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838876 \n",
      "\n",
      "Epoch 331\n",
      "-------------------------------\n",
      "loss: 1.559973  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837758 \n",
      "\n",
      "Epoch 332\n",
      "-------------------------------\n",
      "loss: 1.530436  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837528 \n",
      "\n",
      "Epoch 333\n",
      "-------------------------------\n",
      "loss: 1.559648  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838548 \n",
      "\n",
      "Epoch 334\n",
      "-------------------------------\n",
      "loss: 1.519604  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839115 \n",
      "\n",
      "Epoch 335\n",
      "-------------------------------\n",
      "loss: 1.578704  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839089 \n",
      "\n",
      "Epoch 336\n",
      "-------------------------------\n",
      "loss: 1.559152  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838688 \n",
      "\n",
      "Epoch 337\n",
      "-------------------------------\n",
      "loss: 1.568766  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838336 \n",
      "\n",
      "Epoch 338\n",
      "-------------------------------\n",
      "loss: 1.579056  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838436 \n",
      "\n",
      "Epoch 339\n",
      "-------------------------------\n",
      "loss: 1.549970  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838642 \n",
      "\n",
      "Epoch 340\n",
      "-------------------------------\n",
      "loss: 1.559597  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838670 \n",
      "\n",
      "Epoch 341\n",
      "-------------------------------\n",
      "loss: 1.549964  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838333 \n",
      "\n",
      "Epoch 342\n",
      "-------------------------------\n",
      "loss: 1.570330  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837842 \n",
      "\n",
      "Epoch 343\n",
      "-------------------------------\n",
      "loss: 1.579048  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838116 \n",
      "\n",
      "Epoch 344\n",
      "-------------------------------\n",
      "loss: 1.529602  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838620 \n",
      "\n",
      "Epoch 345\n",
      "-------------------------------\n",
      "loss: 1.628676  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838839 \n",
      "\n",
      "Epoch 346\n",
      "-------------------------------\n",
      "loss: 1.569608  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838576 \n",
      "\n",
      "Epoch 347\n",
      "-------------------------------\n",
      "loss: 1.499769  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838038 \n",
      "\n",
      "Epoch 348\n",
      "-------------------------------\n",
      "loss: 1.569146  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837759 \n",
      "\n",
      "Epoch 349\n",
      "-------------------------------\n",
      "loss: 1.559500  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837949 \n",
      "\n",
      "Epoch 350\n",
      "-------------------------------\n",
      "loss: 1.579235  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838289 \n",
      "\n",
      "Epoch 351\n",
      "-------------------------------\n",
      "loss: 1.578770  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838516 \n",
      "\n",
      "Epoch 352\n",
      "-------------------------------\n",
      "loss: 1.549594  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838427 \n",
      "\n",
      "Epoch 353\n",
      "-------------------------------\n",
      "loss: 1.559132  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837831 \n",
      "\n",
      "Epoch 354\n",
      "-------------------------------\n",
      "loss: 1.549966  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838085 \n",
      "\n",
      "Epoch 355\n",
      "-------------------------------\n",
      "loss: 1.559144  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839216 \n",
      "\n",
      "Epoch 356\n",
      "-------------------------------\n",
      "loss: 1.579250  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839234 \n",
      "\n",
      "Epoch 357\n",
      "-------------------------------\n",
      "loss: 1.579562  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837688 \n",
      "\n",
      "Epoch 358\n",
      "-------------------------------\n",
      "loss: 1.579253  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836643 \n",
      "\n",
      "Epoch 359\n",
      "-------------------------------\n",
      "loss: 1.560068  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837391 \n",
      "\n",
      "Epoch 360\n",
      "-------------------------------\n",
      "loss: 1.549364  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839297 \n",
      "\n",
      "Epoch 361\n",
      "-------------------------------\n",
      "loss: 1.559715  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839837 \n",
      "\n",
      "Epoch 362\n",
      "-------------------------------\n",
      "loss: 1.549290  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839265 \n",
      "\n",
      "Epoch 363\n",
      "-------------------------------\n",
      "loss: 1.550333  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836994 \n",
      "\n",
      "Epoch 364\n",
      "-------------------------------\n",
      "loss: 1.569971  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.835376 \n",
      "\n",
      "Epoch 365\n",
      "-------------------------------\n",
      "loss: 1.559618  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836446 \n",
      "\n",
      "Epoch 366\n",
      "-------------------------------\n",
      "loss: 1.539543  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838219 \n",
      "\n",
      "Epoch 367\n",
      "-------------------------------\n",
      "loss: 1.529966  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839130 \n",
      "\n",
      "Epoch 368\n",
      "-------------------------------\n",
      "loss: 1.549543  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838782 \n",
      "\n",
      "Epoch 369\n",
      "-------------------------------\n",
      "loss: 1.560070  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837855 \n",
      "\n",
      "Epoch 370\n",
      "-------------------------------\n",
      "loss: 1.579403  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836722 \n",
      "\n",
      "Epoch 371\n",
      "-------------------------------\n",
      "loss: 1.550333  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837053 \n",
      "\n",
      "Epoch 372\n",
      "-------------------------------\n",
      "loss: 1.569657  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838719 \n",
      "\n",
      "Epoch 373\n",
      "-------------------------------\n",
      "loss: 1.549622  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839106 \n",
      "\n",
      "Epoch 374\n",
      "-------------------------------\n",
      "loss: 1.578982  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838821 \n",
      "\n",
      "Epoch 375\n",
      "-------------------------------\n",
      "loss: 1.608750  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837919 \n",
      "\n",
      "Epoch 376\n",
      "-------------------------------\n",
      "loss: 1.589136  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836603 \n",
      "\n",
      "Epoch 377\n",
      "-------------------------------\n",
      "loss: 1.559287  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836686 \n",
      "\n",
      "Epoch 378\n",
      "-------------------------------\n",
      "loss: 1.529531  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837810 \n",
      "\n",
      "Epoch 379\n",
      "-------------------------------\n",
      "loss: 1.579508  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838936 \n",
      "\n",
      "Epoch 380\n",
      "-------------------------------\n",
      "loss: 1.559548  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838944 \n",
      "\n",
      "Epoch 381\n",
      "-------------------------------\n",
      "loss: 1.569991  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838176 \n",
      "\n",
      "Epoch 382\n",
      "-------------------------------\n",
      "loss: 1.519615  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836753 \n",
      "\n",
      "Epoch 383\n",
      "-------------------------------\n",
      "loss: 1.549514  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836337 \n",
      "\n",
      "Epoch 384\n",
      "-------------------------------\n",
      "loss: 1.529513  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837575 \n",
      "\n",
      "Epoch 385\n",
      "-------------------------------\n",
      "loss: 1.569240  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838785 \n",
      "\n",
      "Epoch 386\n",
      "-------------------------------\n",
      "loss: 1.570367  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838899 \n",
      "\n",
      "Epoch 387\n",
      "-------------------------------\n",
      "loss: 1.559313  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837826 \n",
      "\n",
      "Epoch 388\n",
      "-------------------------------\n",
      "loss: 1.568672  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835904 \n",
      "\n",
      "Epoch 389\n",
      "-------------------------------\n",
      "loss: 1.558724  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835682 \n",
      "\n",
      "Epoch 390\n",
      "-------------------------------\n",
      "loss: 1.549833  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837142 \n",
      "\n",
      "Epoch 391\n",
      "-------------------------------\n",
      "loss: 1.549595  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838662 \n",
      "\n",
      "Epoch 392\n",
      "-------------------------------\n",
      "loss: 1.540348  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838706 \n",
      "\n",
      "Epoch 393\n",
      "-------------------------------\n",
      "loss: 1.549990  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836655 \n",
      "\n",
      "Epoch 394\n",
      "-------------------------------\n",
      "loss: 1.529610  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835971 \n",
      "\n",
      "Epoch 395\n",
      "-------------------------------\n",
      "loss: 1.529634  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838077 \n",
      "\n",
      "Epoch 396\n",
      "-------------------------------\n",
      "loss: 1.540333  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838630 \n",
      "\n",
      "Epoch 397\n",
      "-------------------------------\n",
      "loss: 1.589300  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837725 \n",
      "\n",
      "Epoch 398\n",
      "-------------------------------\n",
      "loss: 1.569156  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836135 \n",
      "\n",
      "Epoch 399\n",
      "-------------------------------\n",
      "loss: 1.559977  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836380 \n",
      "\n",
      "Epoch 400\n",
      "-------------------------------\n",
      "loss: 1.539681  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838353 \n",
      "\n",
      "Epoch 401\n",
      "-------------------------------\n",
      "loss: 1.569530  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838989 \n",
      "\n",
      "Epoch 402\n",
      "-------------------------------\n",
      "loss: 1.539297  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838154 \n",
      "\n",
      "Epoch 403\n",
      "-------------------------------\n",
      "loss: 1.520251  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836600 \n",
      "\n",
      "Epoch 404\n",
      "-------------------------------\n",
      "loss: 1.550425  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835945 \n",
      "\n",
      "Epoch 405\n",
      "-------------------------------\n",
      "loss: 1.519966  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837177 \n",
      "\n",
      "Epoch 406\n",
      "-------------------------------\n",
      "loss: 1.579007  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837635 \n",
      "\n",
      "Epoch 407\n",
      "-------------------------------\n",
      "loss: 1.550440  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.836842 \n",
      "\n",
      "Epoch 408\n",
      "-------------------------------\n",
      "loss: 1.578321  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835383 \n",
      "\n",
      "Epoch 409\n",
      "-------------------------------\n",
      "loss: 1.589382  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835466 \n",
      "\n",
      "Epoch 410\n",
      "-------------------------------\n",
      "loss: 1.568806  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837423 \n",
      "\n",
      "Epoch 411\n",
      "-------------------------------\n",
      "loss: 1.588807  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838205 \n",
      "\n",
      "Epoch 412\n",
      "-------------------------------\n",
      "loss: 1.540431  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837624 \n",
      "\n",
      "Epoch 413\n",
      "-------------------------------\n",
      "loss: 1.578720  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834797 \n",
      "\n",
      "Epoch 414\n",
      "-------------------------------\n",
      "loss: 1.539298  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834427 \n",
      "\n",
      "Epoch 415\n",
      "-------------------------------\n",
      "loss: 1.500834  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836512 \n",
      "\n",
      "Epoch 416\n",
      "-------------------------------\n",
      "loss: 1.510080  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839144 \n",
      "\n",
      "Epoch 417\n",
      "-------------------------------\n",
      "loss: 1.519621  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839733 \n",
      "\n",
      "Epoch 418\n",
      "-------------------------------\n",
      "loss: 1.549669  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.839446 \n",
      "\n",
      "Epoch 419\n",
      "-------------------------------\n",
      "loss: 1.540337  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838389 \n",
      "\n",
      "Epoch 420\n",
      "-------------------------------\n",
      "loss: 1.539941  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835518 \n",
      "\n",
      "Epoch 421\n",
      "-------------------------------\n",
      "loss: 1.529635  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833988 \n",
      "\n",
      "Epoch 422\n",
      "-------------------------------\n",
      "loss: 1.530135  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834078 \n",
      "\n",
      "Epoch 423\n",
      "-------------------------------\n",
      "loss: 1.530437  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835790 \n",
      "\n",
      "Epoch 424\n",
      "-------------------------------\n",
      "loss: 1.510336  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.838261 \n",
      "\n",
      "Epoch 425\n",
      "-------------------------------\n",
      "loss: 1.539893  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 59.1%, Avg loss: 1.837912 \n",
      "\n",
      "Epoch 426\n",
      "-------------------------------\n",
      "loss: 1.539011  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836040 \n",
      "\n",
      "Epoch 427\n",
      "-------------------------------\n",
      "loss: 1.569258  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.834558 \n",
      "\n",
      "Epoch 428\n",
      "-------------------------------\n",
      "loss: 1.628622  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.834095 \n",
      "\n",
      "Epoch 429\n",
      "-------------------------------\n",
      "loss: 1.558830  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.834264 \n",
      "\n",
      "Epoch 430\n",
      "-------------------------------\n",
      "loss: 1.550447  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835113 \n",
      "\n",
      "Epoch 431\n",
      "-------------------------------\n",
      "loss: 1.559561  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835941 \n",
      "\n",
      "Epoch 432\n",
      "-------------------------------\n",
      "loss: 1.559878  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.836260 \n",
      "\n",
      "Epoch 433\n",
      "-------------------------------\n",
      "loss: 1.589170  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835762 \n",
      "\n",
      "Epoch 434\n",
      "-------------------------------\n",
      "loss: 1.558960  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834982 \n",
      "\n",
      "Epoch 435\n",
      "-------------------------------\n",
      "loss: 1.549895  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834872 \n",
      "\n",
      "Epoch 436\n",
      "-------------------------------\n",
      "loss: 1.569514  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835700 \n",
      "\n",
      "Epoch 437\n",
      "-------------------------------\n",
      "loss: 1.569512  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835846 \n",
      "\n",
      "Epoch 438\n",
      "-------------------------------\n",
      "loss: 1.570137  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835131 \n",
      "\n",
      "Epoch 439\n",
      "-------------------------------\n",
      "loss: 1.549206  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834378 \n",
      "\n",
      "Epoch 440\n",
      "-------------------------------\n",
      "loss: 1.549599  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834131 \n",
      "\n",
      "Epoch 441\n",
      "-------------------------------\n",
      "loss: 1.510350  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834474 \n",
      "\n",
      "Epoch 442\n",
      "-------------------------------\n",
      "loss: 1.598774  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835416 \n",
      "\n",
      "Epoch 443\n",
      "-------------------------------\n",
      "loss: 1.579178  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.835547 \n",
      "\n",
      "Epoch 444\n",
      "-------------------------------\n",
      "loss: 1.539883  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834665 \n",
      "\n",
      "Epoch 445\n",
      "-------------------------------\n",
      "loss: 1.579613  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834275 \n",
      "\n",
      "Epoch 446\n",
      "-------------------------------\n",
      "loss: 1.568870  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834285 \n",
      "\n",
      "Epoch 447\n",
      "-------------------------------\n",
      "loss: 1.520749  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834577 \n",
      "\n",
      "Epoch 448\n",
      "-------------------------------\n",
      "loss: 1.539287  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834702 \n",
      "\n",
      "Epoch 449\n",
      "-------------------------------\n",
      "loss: 1.549424  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834563 \n",
      "\n",
      "Epoch 450\n",
      "-------------------------------\n",
      "loss: 1.549887  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834354 \n",
      "\n",
      "Epoch 451\n",
      "-------------------------------\n",
      "loss: 1.569562  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834168 \n",
      "\n",
      "Epoch 452\n",
      "-------------------------------\n",
      "loss: 1.540353  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834087 \n",
      "\n",
      "Epoch 453\n",
      "-------------------------------\n",
      "loss: 1.550346  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834169 \n",
      "\n",
      "Epoch 454\n",
      "-------------------------------\n",
      "loss: 1.549527  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834349 \n",
      "\n",
      "Epoch 455\n",
      "-------------------------------\n",
      "loss: 1.530307  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834314 \n",
      "\n",
      "Epoch 456\n",
      "-------------------------------\n",
      "loss: 1.578876  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834194 \n",
      "\n",
      "Epoch 457\n",
      "-------------------------------\n",
      "loss: 1.549247  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834157 \n",
      "\n",
      "Epoch 458\n",
      "-------------------------------\n",
      "loss: 1.540062  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834165 \n",
      "\n",
      "Epoch 459\n",
      "-------------------------------\n",
      "loss: 1.548875  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834069 \n",
      "\n",
      "Epoch 460\n",
      "-------------------------------\n",
      "loss: 1.509966  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833964 \n",
      "\n",
      "Epoch 461\n",
      "-------------------------------\n",
      "loss: 1.559616  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834010 \n",
      "\n",
      "Epoch 462\n",
      "-------------------------------\n",
      "loss: 1.568422  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834124 \n",
      "\n",
      "Epoch 463\n",
      "-------------------------------\n",
      "loss: 1.520795  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834061 \n",
      "\n",
      "Epoch 464\n",
      "-------------------------------\n",
      "loss: 1.578867  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833830 \n",
      "\n",
      "Epoch 465\n",
      "-------------------------------\n",
      "loss: 1.539968  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.833905 \n",
      "\n",
      "Epoch 466\n",
      "-------------------------------\n",
      "loss: 1.559591  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834195 \n",
      "\n",
      "Epoch 467\n",
      "-------------------------------\n",
      "loss: 1.579183  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834283 \n",
      "\n",
      "Epoch 468\n",
      "-------------------------------\n",
      "loss: 1.549988  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834203 \n",
      "\n",
      "Epoch 469\n",
      "-------------------------------\n",
      "loss: 1.578774  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834110 \n",
      "\n",
      "Epoch 470\n",
      "-------------------------------\n",
      "loss: 1.539968  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834226 \n",
      "\n",
      "Epoch 471\n",
      "-------------------------------\n",
      "loss: 1.539513  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834334 \n",
      "\n",
      "Epoch 472\n",
      "-------------------------------\n",
      "loss: 1.549743  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834113 \n",
      "\n",
      "Epoch 473\n",
      "-------------------------------\n",
      "loss: 1.568899  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833798 \n",
      "\n",
      "Epoch 474\n",
      "-------------------------------\n",
      "loss: 1.560025  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833827 \n",
      "\n",
      "Epoch 475\n",
      "-------------------------------\n",
      "loss: 1.597995  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834231 \n",
      "\n",
      "Epoch 476\n",
      "-------------------------------\n",
      "loss: 1.569261  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834295 \n",
      "\n",
      "Epoch 477\n",
      "-------------------------------\n",
      "loss: 1.588454  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834030 \n",
      "\n",
      "Epoch 478\n",
      "-------------------------------\n",
      "loss: 1.540064  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833779 \n",
      "\n",
      "Epoch 479\n",
      "-------------------------------\n",
      "loss: 1.529570  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833930 \n",
      "\n",
      "Epoch 480\n",
      "-------------------------------\n",
      "loss: 1.539625  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834193 \n",
      "\n",
      "Epoch 481\n",
      "-------------------------------\n",
      "loss: 1.560129  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834084 \n",
      "\n",
      "Epoch 482\n",
      "-------------------------------\n",
      "loss: 1.539521  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833885 \n",
      "\n",
      "Epoch 483\n",
      "-------------------------------\n",
      "loss: 1.549181  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833884 \n",
      "\n",
      "Epoch 484\n",
      "-------------------------------\n",
      "loss: 1.520433  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833983 \n",
      "\n",
      "Epoch 485\n",
      "-------------------------------\n",
      "loss: 1.589157  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834023 \n",
      "\n",
      "Epoch 486\n",
      "-------------------------------\n",
      "loss: 1.559146  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833847 \n",
      "\n",
      "Epoch 487\n",
      "-------------------------------\n",
      "loss: 1.558969  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833764 \n",
      "\n",
      "Epoch 488\n",
      "-------------------------------\n",
      "loss: 1.550234  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834370 \n",
      "\n",
      "Epoch 489\n",
      "-------------------------------\n",
      "loss: 1.578873  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834569 \n",
      "\n",
      "Epoch 490\n",
      "-------------------------------\n",
      "loss: 1.569575  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834152 \n",
      "\n",
      "Epoch 491\n",
      "-------------------------------\n",
      "loss: 1.529945  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833658 \n",
      "\n",
      "Epoch 492\n",
      "-------------------------------\n",
      "loss: 1.539837  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833507 \n",
      "\n",
      "Epoch 493\n",
      "-------------------------------\n",
      "loss: 1.540196  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833674 \n",
      "\n",
      "Epoch 494\n",
      "-------------------------------\n",
      "loss: 1.540099  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.833942 \n",
      "\n",
      "Epoch 495\n",
      "-------------------------------\n",
      "loss: 1.578837  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834024 \n",
      "\n",
      "Epoch 496\n",
      "-------------------------------\n",
      "loss: 1.519697  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834221 \n",
      "\n",
      "Epoch 497\n",
      "-------------------------------\n",
      "loss: 1.559214  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.0%, Avg loss: 1.834122 \n",
      "\n",
      "Epoch 498\n",
      "-------------------------------\n",
      "loss: 1.559611  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.833705 \n",
      "\n",
      "Epoch 499\n",
      "-------------------------------\n",
      "loss: 1.539258  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.833059 \n",
      "\n",
      "Epoch 500\n",
      "-------------------------------\n",
      "loss: 1.520533  [    0/  232]\n",
      "Test Error: \n",
      " Accuracy: 60.9%, Avg loss: 1.832873 \n",
      "\n",
      "Done!\n"
     ]
    }
   ],
   "source": [
    "for t in range(epochs):\n",
    "    print(f\"Epoch {t+1}\\n-------------------------------\")\n",
    "    train_loop(train_dataloader, model, loss_fn, optimizer)\n",
    "    test_loop(test_dataloader, model, loss_fn)\n",
    "print(\"Done!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "YkMK-FTTHQBP",
    "outputId": "96b983a1-6018-4463-860b-93af8953f29f"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([2, 0, 0, 1, 6, 6, 9, 1, 1, 2, 3, 4, 2, 2, 2, 0, 2, 1, 7, 3, 3, 4, 3, 5,\n",
      "        6, 2, 7, 4, 2, 4, 4, 3, 3, 9, 5, 7, 0, 5, 5, 7, 3, 5, 3, 5, 6, 6, 6, 6,\n",
      "        7, 5, 8, 7, 9, 4, 8, 4, 6, 7, 8, 0, 7, 5, 5, 6, 6, 3, 7, 7, 7, 1, 3, 4,\n",
      "        6, 0, 0, 3, 6, 1, 2, 4, 3, 9, 0, 4, 3, 3, 0, 1, 9, 8, 1, 1, 7, 8, 2, 0,\n",
      "        3, 5, 7, 9]) \n",
      " tensor([2, 0, 6, 1, 6, 6, 8, 2, 6, 5, 2, 3, 5, 4, 5, 0, 3, 6, 9, 3, 3, 3, 3, 2,\n",
      "        6, 5, 0, 5, 3, 3, 3, 3, 5, 9, 6, 7, 0, 5, 5, 7, 3, 6, 3, 5, 7, 6, 6, 7,\n",
      "        7, 5, 8, 7, 9, 5, 8, 4, 6, 8, 8, 0, 6, 5, 6, 6, 6, 3, 6, 7, 7, 1, 3, 4,\n",
      "        6, 0, 0, 3, 6, 2, 2, 4, 3, 8, 0, 4, 3, 3, 0, 1, 8, 9, 6, 6, 0, 8, 2, 9,\n",
      "        2, 5, 7, 9])\n",
      "0.6\n"
     ]
    }
   ],
   "source": [
    "dat = next(iter(test_dataloader))\n",
    "pred = model(dat['x'])\n",
    "\n",
    "print(dat['y'].argmax(axis=1),'\\n', pred.argmax(axis=1))\n",
    "\n",
    "print(np.sum((dat['y'].argmax(axis=1).detach().numpy()==pred.argmax(axis=1).detach().numpy()).astype(int))/len(pred))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "B9bjP5GnMIG_",
    "outputId": "3e01141e-3ab8-4ab9-87d5-fc6ff22aa0aa"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([1, 3, 4, 3, 8, 4, 5, 7, 3, 4, 4, 3, 8, 8, 3, 2, 2, 3, 8, 1, 6, 0, 1, 3,\n",
      "        4, 4, 8, 0, 2, 6, 9, 2, 7, 7, 2, 1, 7, 8, 9, 5, 2, 5, 4, 0, 3, 0, 5, 1,\n",
      "        8, 2, 5, 3, 5, 9, 5, 1, 1, 2, 3, 3, 6, 0, 0, 0, 7, 6, 0, 1, 5, 9, 9, 5,\n",
      "        3, 6, 5, 0, 6, 1, 8, 6, 4, 4, 8, 4, 4, 2, 3, 5, 1, 4, 1, 8, 7, 7, 8, 4,\n",
      "        5, 2, 5, 5]) \n",
      " tensor([1, 3, 3, 3, 8, 4, 5, 7, 3, 4, 4, 3, 8, 8, 3, 2, 2, 3, 8, 1, 6, 0, 1, 3,\n",
      "        4, 4, 8, 0, 2, 6, 9, 2, 7, 7, 3, 1, 7, 8, 9, 5, 3, 5, 4, 0, 3, 0, 5, 6,\n",
      "        8, 2, 5, 3, 2, 9, 5, 1, 1, 2, 3, 3, 6, 0, 0, 0, 3, 6, 0, 1, 5, 9, 9, 5,\n",
      "        3, 6, 2, 0, 1, 1, 8, 6, 4, 4, 8, 4, 4, 2, 3, 5, 1, 4, 1, 8, 7, 7, 8, 4,\n",
      "        5, 3, 5, 5])\n",
      "0.91\n"
     ]
    }
   ],
   "source": [
    "dat = next(iter(train_dataloader))\n",
    "pred = model(dat['x'])\n",
    "\n",
    "print(dat['y'].argmax(axis=1),'\\n', pred.argmax(axis=1))\n",
    "print(np.sum((dat['y'].argmax(axis=1).detach().numpy()==pred.argmax(axis=1).detach().numpy()).astype(int))/len(pred))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "t-tKElwrPZ5i",
    "outputId": "cb7de785-e3c0-4afa-b129-a56bb5c519a4"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cloning into 'stable-diffusion-webui'...\n",
      "remote: Enumerating objects: 8650, done.\u001B[K\n",
      "remote: Counting objects: 100% (169/169), done.\u001B[K\n",
      "remote: Compressing objects: 100% (145/145), done.\u001B[K\n",
      "remote: Total 8650 (delta 111), reused 50 (delta 24), pack-reused 8481\u001B[K\n",
      "Receiving objects: 100% (8650/8650), 22.57 MiB | 19.10 MiB/s, done.\n",
      "Resolving deltas: 100% (6068/6068), done.\n"
     ]
    }
   ],
   "source": [
    "!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "tIwdyC_pPom1",
    "outputId": "fe3e000d-5b11-4481-d9d5-fb92b07e7be2"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cloning into 'first-order-model'...\n",
      "remote: Enumerating objects: 333, done.\u001B[K\n",
      "remote: Counting objects: 100% (27/27), done.\u001B[K\n",
      "remote: Compressing objects: 100% (19/19), done.\u001B[K\n",
      "remote: Total 333 (delta 13), reused 18 (delta 8), pack-reused 306\u001B[K\n",
      "Receiving objects: 100% (333/333), 72.16 MiB | 22.69 MiB/s, done.\n",
      "Resolving deltas: 100% (172/172), done.\n"
     ]
    }
   ],
   "source": [
    "!git clone https://github.com/AliaksandrSiarohin/first-order-model"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "provenance": []
  },
  "kernelspec": {
   "name": "myiste",
   "language": "python",
   "display_name": "my_test_jupyter"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}